<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>轮播图</title>
</head>
<style>
    .container{
        width: 675px;
        height: 960px;
        margin: auto;
    }
    img{
        width: 675px;
    }
</style>
<script>
    onload = function () {
        setInterval(changeImg, 3000)
    }
    let i = 1;

    function changeImg() {
        let imgObj = document.getElementById("imgId");
        imgObj.src = "img/" + i + ".jpg";
        i++;
        if (i == 5) {
            i = 0;
        }
    }
</script>
<body>
<div class="container">
    <img src="img/0.jpg" id="imgId">
</div>
</body>
</html>